{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1243
  Verdict: Accepted
}
var
   i,j,ls,k,code,cur:longint;
   s,t:string;
   ch:char;
 
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
read(ch);
while ch in ['0'..'9','A'..'Z'] do begin
      s:=s+ch;
      read(ch);
end;
t:='';
ls:=length(s);
cur:=0;
for i:=1 to ls do begin
    if s[i] in ['0'..'9'] then t:=t+s[i];
    if (s[i] in ['A'..'Z']) and (t='') then begin
       inc(cur);
       write(s[i]);
       if cur=40 then begin
          writeln;
          cur:=0;
       end;
    end else
    if (not (s[i] in ['0'..'9'])) or (i=ls) then begin
       val(t,k,code);
       for j:=1 to k do begin
           inc(cur);
           write(s[i]);
           if cur=40 then begin
              writeln;
              cur:=0;
           end;
       end;
       t:='';
    end;
end;
writeln;
end.